package com.hh.core.config;

import org.beetl.core.resource.ClasspathResourceLoader;
import org.beetl.ext.spring.BeetlSpringViewResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.hh.core.beetl.BeetlConfiguration;
import com.hh.core.property.BaseProperty;
import com.hh.core.property.BeetlProperty;

/**
 * 
* @ClassName: BeetlConfig  
* @Description: TODO(Beetl模板配置类)  
* @author hxn
* @date 2018年1月12日 下午3:20:55  
*
 */
@Configuration
public class BeetlConfig {

	@Autowired
    BeetlProperty beetlProperty;
	
	@Autowired
	BaseProperty baseProperty;
	
	/**
	 * 
	* @Title: getBeetlGroupUtilConfiguration  
	* @Description:   beetl初始化配置
	* @param @return    设定文件  
	* @return BeetlGroupUtilConfiguration    返回类型  
	* @author hxn
	* @date 2018年1月12日 下午3:22:27  
	* @throws
	 */
	@Bean(initMethod = "init")
	public BeetlConfiguration getBeetlGroupUtilConfiguration() {
		BeetlConfiguration beetlConfiguration = new BeetlConfiguration(baseProperty);
		ClasspathResourceLoader cploder = new ClasspathResourceLoader(BeetlConfig.class.getClassLoader(),beetlProperty.getPrefix());
		beetlConfiguration.setResourceLoader(cploder);
		beetlConfiguration.setConfigProperties(beetlProperty.getProperties());
		return beetlConfiguration;
	}
	
	/**
	 * 
	* @Title: getBeetlSpringViewResolver  
	* @Description:   beetl的视图解析器
	* @param @return    设定文件  
	* @return BeetlSpringViewResolver    返回类型  
	* @author hxn
	* @date 2018年1月12日 下午3:23:02  
	* @throws
	 */
	@Bean
    public BeetlSpringViewResolver getBeetlSpringViewResolver() {
        BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
        beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
        beetlSpringViewResolver.setOrder(0);
        beetlSpringViewResolver.setConfig(getBeetlGroupUtilConfiguration());
        return beetlSpringViewResolver;
    }
}
